/*
 * NumFormat.java
 *
 * Created on 26 de marzo de 2007, 09:24 AM
 *
 
 */

package inc.jmc.cyberboard.common;

import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 *
 * @author Juan Miguel Olguin Salguero
 */
public class NumFormat {
	public static final Locale LOCAL_MX = new Locale("es","MX"); 
	
	private static NumberFormat floatFormatter= null;
    static{
        floatFormatter = NumberFormat.getNumberInstance(LOCAL_MX); 
        floatFormatter.setMinimumFractionDigits(2);
        floatFormatter.setMaximumFractionDigits(2);
        //floatFormatter.setGroupingUsed(false);
        floatFormatter.setGroupingUsed(true);
    }
    private NumFormat() {
    }
    public static String money(double money)
    {
        return floatFormatter.format(money);
    }
    public static float parseMoney(String money)
    {
    	float value = 0;
    	try {
			value=floatFormatter.parse(money).floatValue();
		} catch (ParseException e) {
			
			e.printStackTrace();
		}
        return value;
    }
    public static String money(Float money)
    {
        return NumFormat.money(money.floatValue());
    }
    public static String money(Double money)
    {
        return NumFormat.money(money.doubleValue());
    }
    public static final SimpleDateFormat sdf_dd_MM_yyyy = new SimpleDateFormat("dd/MM/yyyy",LOCAL_MX);
    public static final SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat("yyyyMMdd",LOCAL_MX);
    public static final SimpleDateFormat sdf_yyyy_MM_dd_guiones = new SimpleDateFormat("yyyy-MM-dd",LOCAL_MX);
	public static final SimpleDateFormat sdf_dd = new SimpleDateFormat("dd",LOCAL_MX);
	public static final SimpleDateFormat sdf_mm = new SimpleDateFormat("MM",LOCAL_MX);
	public static final SimpleDateFormat sdf_yyyy = new SimpleDateFormat("yyyy",LOCAL_MX);
	public static final SimpleDateFormat sdf_EEEEE_dd = new SimpleDateFormat("EEEEE, d",LOCAL_MX);
	public static final SimpleDateFormat sdf_MMMMM = new SimpleDateFormat("MMMMM",LOCAL_MX);
	public static final SimpleDateFormat sdf_hh_mm_ss = new SimpleDateFormat("HH:mm:ss",LOCAL_MX);
	public static final SimpleDateFormat sdf_ddMMyyyy_hhmmss = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",LOCAL_MX);
	public static String toLongDate(Date date1)
	{
		String dia=sdf_EEEEE_dd.format(date1);
		char upp=Character.toUpperCase(dia.charAt(0));
		dia=""+upp+dia.substring(1);
		String mes=sdf_MMMMM.format(date1);
		upp=Character.toUpperCase(mes.charAt(0));
		mes=""+upp+mes.substring(1);
		return dia +" de "+ mes +" de "+sdf_yyyy.format(date1);
		
	}
	public static final NumberFormat nf_00 = NumberFormat.getInstance(LOCAL_MX);
	static {
		nf_00.setMaximumFractionDigits(2);
		nf_00.setMinimumFractionDigits(2);
		nf_00.setGroupingUsed(false);
	}
	public static final NumberFormat nf_0 = NumberFormat.getInstance(LOCAL_MX);
	static {
		nf_0.setMaximumFractionDigits(1);
		nf_0.setMinimumFractionDigits(1);
		nf_0.setGroupingUsed(false);
	}
	
	public static final NumberFormat nf_comas_00 = NumberFormat.getInstance(LOCAL_MX);
	static {
		nf_comas_00.setMaximumFractionDigits(2);
		nf_comas_00.setMinimumFractionDigits(2);
		nf_comas_00.setGroupingUsed(true);
	}
	public static final NumberFormat dos_Enteros_00 = NumberFormat.getInstance(LOCAL_MX);
	static {
		dos_Enteros_00.setMinimumIntegerDigits(2);
	}
	public static final SimpleDateFormat sdf_hh_mm_ss_DiferenciaCronometros = new SimpleDateFormat("HH:mm:ss",LOCAL_MX);
	static {
		sdf_hh_mm_ss_DiferenciaCronometros.setTimeZone(TimeZone.getTimeZone("GMT"));
	}
	
}
